<html>
	<head>
	</head>
	<body>
	
<?php
/*
 * Created on 25 janv. 2009
 * Created by Ludovic Reenaers
 * lreenaers@hotmail.com
 */
 
 //  remove;getAll
require("factories/DAOFactory.php");
$factory = new DAOFactory();
$DAO = $factory->getLangueDAO();
echo "******  TEST LANGUE DAO ******<br/>";
echo "<table width='60%' border='1'><tr>";
echo "<th> Test </th><th> Status </th></tr>";
if ($DAO->getById(1)->getAbr() == "fr"){
	echo "<tr><td> getById() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> getById() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->getByAbr("fr")->getId() == 1){
	echo "<tr><td> getByAbr() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> getByAbr() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->update($DAO->getByAbr("fr")) == true){
	echo "<tr><td> update() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> update() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
$lng = $DAO->add("dk");
if ($lng->getAbr()=="dk"){
	echo "<tr><td> add() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> add() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->remove($lng)==true){
	echo "<tr><td> remove() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> remove() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if (count($DAO->all())>0){
	echo "<tr><td> All() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> All() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
echo "</table>";


$DAO = $factory->getNomCategorieDAO();
echo "******  TEST NOM CATEGORIE DAO ******<br/>";
echo "<table width='60%' border='1'><tr>";
echo "<th> Test </th><th> Status </th></tr>";
if ($DAO->getById(1)->getValue() == "root"){
	echo "<tr><td> getById() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> getById() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->getByValue("root")->getId() == 1){
	echo "<tr><td> getByValue() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> getByValue() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->update($DAO->getByValue("root")) == true){
	echo "<tr><td> update() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> update() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
$bean = $DAO->add("test1");
if ($bean->getValue()=="test1"){
	echo "<tr><td> add() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> add() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->remove($bean)==true){
	echo "<tr><td> remove() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> remove() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if (count($DAO->all())>0){
	echo "<tr><td> All() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> All() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
echo "</table>";

$DAO = $factory->getTooltipDAO();
echo "******  TEST TOOLTIP DAO ******<br/>";
echo "<table width='60%' border='1'><tr>";
echo "<th> Test </th><th> Status </th></tr>";
if ($DAO->getById(1)->getValue() == "root"){
	echo "<tr><td> getById() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> getById() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->getByValue("root")->getId() == 1){
	echo "<tr><td> getByValue() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> getByValue() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->update($DAO->getByValue("root")) == true){
	echo "<tr><td> update() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> update() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
$bean = $DAO->add("test1");
if ($bean->getValue()=="test1"){
	echo "<tr><td> add() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> add() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if ($DAO->remove($bean)==true){
	echo "<tr><td> remove() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> remove() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
if (count($DAO->all())>0){
	echo "<tr><td> All() </td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> All() </td><td bgcolor=\"red\"> Failure !</td></tr>";
}
echo "</table>";

$DAO = $factory->getCategorieDAO();
echo "******  TEST CATEGORIE DAO ******<br/>";

echo "<table width='60%' border='1'><tr>";
echo "<th> Test </th><th> Status </th></tr>";
echo "<tr><td colspan='2' bgcolor='orange''> getById()</td></tr>";
$bean = $DAO->getById(1);
if ($bean==null){
	echo "merdeee";
}
if($bean->getParent() == null){
	echo "<tr><td> parent must be null for root categorie</td><td bgcolor=\"green\"> Succeed !</td></tr>";
}else{
	echo "<tr><td> parent must be null for root categorie</td><td bgcolor=\"red\"> Failure !</td></tr>";
}
//if(){
//	echo "<tr><td></td><td bgcolor=\"green\"> Succeed !</td></tr>";
//}else{
//	echo "<tr><td></td><td bgcolor=\"red\"> Failure !</td></tr>";
//}
//if(){
//	echo "<tr><td></td><td bgcolor=\"green\"> Succeed !</td></tr>";
//}else{
//	echo "<tr><td></td><td bgcolor=\"red\"> Failure !</td></tr>";
//}
//if(){
//	echo "<tr><td></td><td bgcolor=\"green\"> Succeed !</td></tr>";
//}else{
//	echo "<tr><td></td><td bgcolor=\"red\"> Failure !</td></tr>";
//}
//if(){
//	echo "<tr><td></td><td bgcolor=\"green\"> Succeed !</td></tr>";
//}else{
//	echo "<tr><td></td><td bgcolor=\"red\"> Failure !</td></tr>";
//}

echo "</table>";
?>
	</body>
</html>